package sundun.sharding.condition;

import org.springframework.boot.autoconfigure.condition.ConditionOutcome;
import org.springframework.boot.autoconfigure.condition.SpringBootCondition;
import org.springframework.context.annotation.ConditionContext;
import org.springframework.core.type.AnnotatedTypeMetadata;
import sundun.sharding.constant.ShardingConstant;

/**
 * 执行器组装条件
 * @author: zxl
 * @date: 2024/8/10 4:57
 */
public class ExecutionCondition extends SpringBootCondition {



    @Override
    public ConditionOutcome getMatchOutcome(ConditionContext context, AnnotatedTypeMetadata metadata) {
        return context.getBeanFactory().containsBean(ShardingConstant.SHARDING_DATA_SOURCE_NAME) ? ConditionOutcome.match() : ConditionOutcome.noMatch("has not bean shardingDataSource");
    }
}
